package com.nbsaas.boot.quartz.rest.convert;

import com.nbsaas.boot.quartz.data.entity.SchedulingTaskRecord;
import com.nbsaas.boot.quartz.api.domain.response.SchedulingTaskRecordResponse;

import com.nbsaas.boot.utils.BeanDataUtils;
import com.nbsaas.boot.rest.api.Converter;

/**
 * 定时任务记录-实体对象转化成响应对象
 */

public class SchedulingTaskRecordResponseConvert implements Converter<SchedulingTaskRecordResponse, SchedulingTaskRecord> {

    @Override
    public SchedulingTaskRecordResponse convert(SchedulingTaskRecord source) {
        SchedulingTaskRecordResponse result = new SchedulingTaskRecordResponse();
        BeanDataUtils.copyProperties(source, result);
        if (source.getSchedulingTask() != null) {
            result.setSchedulingTask(source.getSchedulingTask().getId());
        }

        try {
            if (source.getSchedulingTask() != null) {
                result.setSchedulingTaskName(source.getSchedulingTask().getName());
            }
        } catch (Exception ignored) {
        }

        return result;
    }

}

